<!-- JSF Core tag library documentation
  -  Copyright (C) 2012 Stephane Carrez
  -  Written by Stephane Carrez (Stephane.Carrez@gmail.com)
  -
  -  Licensed under the Apache License, Version 2.0 (the "License");
  -  you may not use this file except in compliance with the License.
  -  You may obtain a copy of the License at
  -
  -      http://www.apache.org/licenses/LICENSE-2.0
  -
  -  Unless required by applicable law or agreed to in writing, software
  -  distributed under the License is distributed on an "AS IS" BASIS,
  -  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  -  See the License for the specific language governing permissions and
  -  limitations under the License.
  -->
<c:choose xmlns:c="http://java.sun.com/jstl/core"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:ui="http://java.sun.com/jsf/facelets"
          xmlns:util="http://code.google.com/p/ada-asf/util">
    <!-- For security reasons, check that the code parameter matches what is allowed  -->

    <c:when test="#{empty param['code'] or param['code'] eq 'attribute'}">
        <ui:decorate template="/WEB-INF/layouts/doc.xhtml">
            <ui:param name="name" value="f:attribute"/>
            <ui:define name="description">
                This tag associates an attribute with the nearest parent <tt>UIComponent</tt>.
                When the value is not an EL expression, this tag has the same effect as calling
                <tt>Component.Set_Attribute (Name, Value)</tt>. When the attribute name specified
                matches a standard property of the component, that property is set.
                However it is also valid to assign attributes to components using any
                arbitrary name; the component itself won't make any use of these but
                other objects such as custom renderers, validators or action listeners
                can later retrieve the attribute from the component by name.

                <br></br>
                When the value is an EL expression, this tag has the same effect as
                calling <tt>Component.Set_Attribute (Tag, Value)</tt>. A call to method
                <tt>Component.Get_Attribute (Name)</tt> will then cause that expression to
                be evaluated and the result of the expression is returned,
                not the original EL expression string.

                See the <tt>ASF.Components.Base</tt> package for more details.

                Unless otherwise specified, all attributes accept static values or EL expressions.

                Sets the specified name and attribute on the parent UIComponent.
                If the "value" specified is not a literal, it will instead set the ValueExpression
                on the UIComponent.

            </ui:define>
            <ui:define name="attributes">
                <li class="attr-optional">
                    <b>name</b>
                    <i>String</i>
                    <span>The name of the attribute.</span>
                </li>
                <li class="attr-optional">
                    <b>value</b>
                    <i>String</i>
                    <span>The attribute's value.</span>
                </li>
            </ui:define>
        </ui:decorate>
    </c:when>

    <c:when test="#{param['code'] eq 'converter'}">
        <ui:decorate template="/WEB-INF/layouts/doc.xhtml">
            <ui:param name="name" value="f:converter"/>
            <ui:define name="description">
                This tag creates an instance of the specified Converter, and associates it
                with the nearest parent UIComponent.

                <br></br>
                Register a named Converter instance on the UIComponent associated with the
                closest parent UIComponent custom action.

            </ui:define>
            <ui:define name="attributes">
                <li class="attr-required">
                    <b>converterId</b>
                    <i>String</i>
                    <span>The converter's registered identifier.</span>
                </li>
                <li class="attr-unimpl">
                    <b>for</b>
                    <i>String</i>
                    <span>The component onto which the converter is associated.</span>
                </li>
                <li class="attr-unimpl">
                    <b>binding</b>
                    <i>ValueExpression</i>
                    <span>A <tt>ValueExpression</tt> that evaluates to a Converter.</span>
                </li>
            </ui:define>
        </ui:decorate>
    </c:when>

    <c:when test="#{param['code'] eq 'metadata'}">
        <ui:decorate template="/WEB-INF/layouts/doc.xhtml">
            <ui:param name="name" value="f:metadata"/>
            <ui:define name="description">
                Declares the metadata facet for the view.
            </ui:define>
            <ui:define name="attributes">
                <li>
                    none
                </li>
            </ui:define>
        </ui:decorate>
    </c:when>

    <c:when test="#{param['code'] eq 'param'}">
        <ui:decorate template="/WEB-INF/layouts/doc.xhtml">
            <ui:param name="name" value="f:param"/>
            <ui:define name="description">
                This tag associates a parameter name-value pair with the nearest parent UIComponent.
                A UIComponent is created to represent this name-value pair, and stored as a child
                of the parent component; what effect this has depends upon the renderer of that
                parent component.

                <br></br>
                Unless otherwise specified, all attributes accept static values or EL expressions.

            </ui:define>
            <ui:define name="attributes">
                <li class="attr-optional">
                    <b>name</b>
                    <i>String</i>
                    <span>The name under which the value is stored.</span>
                </li>
                <li class="attr-optional">
                    <b>value</b>
                    <i>String</i>
                    <span>The value of this component.</span>
                </li>
                <li class="attr-optional">
                    <b>id</b>
                    <i>String</i>
                    <span>Get a string which uniquely identifies this UIComponent within
                    the nearest ancestor naming component.</span>
                </li>
                <li class="attr-unimpl">
                    <b>binding</b>
                    <i>ValueExpression</i>
                    <span>A <tt>ValueExpression</tt> that evaluates to a UIComponent.</span>
                </li>
            </ui:define>
        </ui:decorate>
    </c:when>

    <c:when test="#{param['code'] eq 'selectItem'}">
        <ui:decorate template="/WEB-INF/layouts/doc.xhtml">
            <ui:param name="name" value="f:selectItem"/>
            <ui:define name="description">
                This tag associates a single <tt>SelectItem</tt> with the nearest parent UIComponent.
                The item represents a single option for a component such as an
                <tt>h:selectBooleanCheckbox</tt> or <tt>h:selectOneMenu</tt>.
                See also component <tt>selectItems</tt>.

                <br></br>
                Unless otherwise specified, all attributes accept static values or EL expressions.

                <br></br>
                UISelectItem should be nested inside a <tt>UISelectMany</tt> or
                <tt>UISelectOne</tt> component, and results in the addition of a <tt>SelectItem</tt>
                instance to the list of available options for the parent component
            </ui:define>
            <ui:define name="attributes">
                <li class="attr-optional">
                    <b>itemDisabled</b>
                    <i>Boolean</i>
                    <span>Determine whether this item can be chosen by the user.
                        When true, this item cannot be chosen by the user.
                        If this method is ever called, then any EL-binding for the disabled property
                        will be ignored.</span>
                </li>
                <li class="attr-optional">
                    <b>escape</b>
                    <i>Boolean</i>
                    <span>The escape setting for the label of this selection item.</span>
                </li>
                <li class="attr-optional">
                    <b>itemDescription</b>
                    <i>String</i>
                    <span>.</span>
                </li>
                <li class="attr-optional">
                    <b>itemLabel</b>
                    <i>String</i>
                    <span>The string which will be presented to the user for this option.</span>
                </li>
                <li class="attr-optional">
                    <b>itemValue</b>
                    <i>String</i>
                    <span>The value for this item.</span>
                </li>
                <li class="attr-optional">
                    <b>value</b>
                    <i>ValueExpression</i>
                    <span>The initial value of this component.</span>
                </li>
                <li class="attr-unimpl">
                    <b>noSelectionOptions</b>
                    <i>Boolean</i>
                    <span>Indicate this component represent no selection option. Default value is false.</span>
                </li>
                <li class="attr-unimpl">
                    <b>binding</b>
                    <i>ValueExpression</i>
                    <span>A <tt>ValueExpression</tt> that evaluates to a UIComponent.</span>
                </li>
            </ui:define>
        </ui:decorate>
    </c:when>

    <c:when test="#{param['code'] eq 'selectItems'}">
        <ui:decorate template="/WEB-INF/layouts/doc.xhtml">
            <ui:param name="name" value="f:selectItems"/>
            <ui:define name="description">
                This tag associates a list of <tt>SelectItem</tt> with the nearest parent UIComponent.
                The list of items is retrieved via a value-binding.
                See also component <tt>selectItem</tt>.

                <br></br>
                Unless otherwise specified, all attributes accept static values or EL expressions.

                <br></br>
                UISelectItem should be nested inside a <tt>UISelectMany</tt> or
                <tt>UISelectOne</tt> component, and results in the addition of one or more <tt>SelectItem</tt>
                instance to the list of available options for the parent component.
            </ui:define>
            <ui:define name="attributes">
                <li class="attr-optional">
                    <b>itemDisabled</b>
                    <i>Boolean</i>
                    <span>Determine whether this item can be chosen by the user.
                        When true, this item cannot be chosen by the user.
                        If this method is ever called, then any EL-binding for the disabled property
                        will be ignored.</span>
                </li>
                <li class="attr-optional">
                    <b>itemLabelEscaped</b>
                    <i>Boolean</i>
                    <span>The escape setting for the label of this selection item.</span>
                </li>
                <li class="attr-optional">
                    <b>itemDescription</b>
                    <i>String</i>
                    <span>The description of the current item.</span>
                </li>
                <li class="attr-optional">
                    <b>itemLabel</b>
                    <i>String</i>
                    <span>The string which will be presented to the user for this option.</span>
                </li>
                <li class="attr-optional">
                    <b>itemValue</b>
                    <i>String</i>
                    <span>The value for this item.</span>
                </li>
                <li class="attr-required">
                    <b>value</b>
                    <i>ValueExpression</i>
                    <span>The initial value of this component.</span>
                </li>
                <li class="attr-unimpl">
                    <b>var</b>
                    <i>String</i>
                    <span>Name of a request-scope attribute under which the current item of the collection,
                        array, etc. of the value attribute will be exposed so that it can be referred to in EL
                        for other attributes of this component.
                    </span>
                </li>
                <li class="attr-unimpl">
                    <b>noSelectionValue</b>
                    <i>Boolean</i>
                    <span>Is either an EL expression pointing to the element in the value collection whose value
                        should be marked as a "no selection" item, or a literal string that exactly matches the
                        value of the item in the collection that must be marked as the "no selection" item.
                        If the user selects such an item and the field is marked as required, then it will
                        not pass validation.
                    </span>
                </li>
                <li class="attr-unimpl">
                    <b>binding</b>
                    <i>ValueExpression</i>
                    <span>A <tt>ValueExpression</tt> that evaluates to a UIComponent.</span>
                </li>
            </ui:define>
        </ui:decorate>
    </c:when>

    <c:when test="#{param['code'] eq 'validateLength'}">
        <ui:decorate template="/WEB-INF/layouts/doc.xhtml">
            <ui:param name="name" value="f:validateLength"/>
            <ui:define name="description">
                Creates a validator and associates it with the nearest parent <tt>UIComponent</tt>.
                When invoked, the validator ensures that values are valid strings with a length
                that lies within the minimum and maximum values specified. Commonly associated
                with a <tt>h:inputText</tt> entity. Unless otherwise specified, all attributes
                accept static values or EL expressions.
            </ui:define>
            <ui:define name="attributes">
                <li class="attr-optional">
                    <b>maximum</b>
                    <i>Natural</i>
                    <span>The largest value that should be considered valid.</span>
                </li>
                <li class="attr-optional">
                    <b>minimum</b>
                    <i>Natural</i>
                    <span>The smallest value that should be considered valid.</span>
                </li>
            </ui:define>
        </ui:decorate>
    </c:when>

    <c:when test="#{param['code'] eq 'validateLongRange'}">
        <ui:decorate template="/WEB-INF/layouts/doc.xhtml">
            <ui:param name="name" value="f:validateLongRange"/>
            <ui:define name="description">
                Creates a validator and associates it with the nearest parent <tt>UIComponent</tt>.
                When invoked, the validator ensures that values are valid longs that lie within the
                minimum and maximum values specified. Commonly associated
                with a <tt>h:inputText</tt> entity. Unless otherwise specified, all attributes
                accept static values or EL expressions.
            </ui:define>
            <ui:define name="attributes">
                <li class="attr-optional">
                    <b>maximum</b>
                    <i>Long</i>
                    <span>The largest value that should be considered valid.</span>
                </li>
                <li class="attr-optional">
                    <b>minimum</b>
                    <i>Long</i>
                    <span>The smallest value that should be considered valid.</span>
                </li>
            </ui:define>
        </ui:decorate>
    </c:when>

    <c:when test="#{param['code'] eq 'validator'}">
        <ui:decorate template="/WEB-INF/layouts/doc.xhtml">
            <ui:param name="name" value="f:validator"/>
            <ui:define name="description">
                Creates a validator and associates it with the nearest parent UIComponent.
                <br></br>
                During the validation phase (or the apply-request-values phase for immediate components),
                if the associated component has any submitted value and the conversion of that
                value to the required type has succeeded then the specified validator type is invoked
                to test the validity of the converted value.
                <br></br>
                Commonly associated with an h:inputText entity, but may be applied to any input component.
                Some validators may allow the component to use attributes to define component-specific
                validation constraints; see the f:attribute tag. See also the "validator" attribute of
                all input components, which allows a component to specify an arbitrary validation
                <i>method</i> (rather than a registered validation type, as this tag does).
                <br></br>
                Unless otherwise specified, all attributes accept static values or EL expressions.
            </ui:define>
            <ui:define name="attributes">
                <li class="attr-optional">
                    <b>validatorId</b>
                    <i>String</i>
                    <span>The registered ID of the desired Validator.</span>
                </li>
                <li class="attr-unimpl">
                    <b>disabled</b>
                    <i>Boolean</i>
                    <span>When true, disable the validator.  Defaults to false.</span>
                </li>
            </ui:define>
        </ui:decorate>
    </c:when>

    <c:when test="#{param['code'] eq 'view-example'}">
        <ui:decorate template="/WEB-INF/layouts/doc.xhtml">
            <ui:param name="name" value="f:view"/>
            <ui:define name="description">
                Creates a JSF View, which is a container that holds all of the components
                that are part of the view.  The <tt>UIView</tt> represents the root of
                the component tree.

                <br></br>
                Unless otherwise specified, all attributes accept static values or EL expressions.
            </ui:define>
            <ui:define name="attributes">
                <li class="attr-optional">
                    <b>locale</b>
                    <i>String</i>
                    <span>The locale of this view. Default: the default locale from the configuration file.</span>
                </li>
                <li class="attr-optional">
                    <b>contentType</b>
                    <i>String</i>
                    <span>The content type to be placed in the response header.
                    The default content type is <tt>text/html</tt>.</span>
                </li>
            </ui:define>
        </ui:decorate>
    </c:when>

    <c:when test="#{param['code'] eq 'viewAction'}">
        <ui:decorate template="/WEB-INF/layouts/doc.xhtml">
            <ui:param name="name" value="f:viewAction"/>
            <ui:define name="description">
                The viewAction element is used in a medata facet.  It allows to execute an Ada bean action
                method when a request is processed. The Ada bean method is executed before rendering the page.
            </ui:define>
            <ui:define name="attributes">
                <ui:include src="../html/doc-actions.xhtml"/>
            </ui:define>
        </ui:decorate>
    </c:when>

    <c:when test="#{param['code'] eq 'viewParam'}">
        <ui:decorate template="/WEB-INF/layouts/doc.xhtml">
            <ui:param name="name" value="f:viewParam"/>
            <ui:define name="description">
                The viewParam element is used in a medata facet.  It allows to initialize
                a bean attribute from a request parameter.
            </ui:define>
            <ui:define name="attributes">
                <ui:include src="../html/doc-converter.xhtml"/>
                <ui:include src="../html/doc-common.xhtml"/>
                <ui:include src="../html/doc-input.xhtml"/>

                <li class="attr-unimpl">
                    <b>binding</b>
                    <i>ValueExpression</i>
                    <span>A <tt>ValueExpression</tt> that evaluates to a UIComponent.</span>
                </li>
            </ui:define>
        </ui:decorate>
    </c:when>

    <c:when test="#{param['code'] eq 'script'}">
        <ui:decorate template="/WEB-INF/layouts/doc.xhtml">
            <ui:param name="name" value="util:script"/>
            <ui:define name="description">
                In the render response phase, queue some javascript code in the response stream.
                The javascript code is automatically flushed before sending the response stream.
                It can be flushed explicitly by using the <b>util:flush</b> component.
            </ui:define>
            <ui:define name="attributes">
                <li class="attr-optional">
                    <b>rendered</b>
                    <i>Boolean</i>
                    <span>Flag indicating whether or not this component should be rendered (during Render Response Phase),
                        or processed on any subsequent form submit. The default value for this property is true.</span>
                </li>
            </ui:define>
        </ui:decorate>
    </c:when>
    <c:when test="#{param['code'] eq 'view'}">
        <ui:decorate template="/WEB-INF/layouts/doc.xhtml">
            <ui:param name="name" value="util:view"/>
            <ui:define name="description">
                Create a root view component.
            </ui:define>
            <ui:define name="attributes">
                <li class="attr-required">
                    <b></b>
                    <i></i>
                    <span>No attributes defined</span>
                </li>
            </ui:define>
        </ui:decorate>
    </c:when>

    <c:otherwise>
        <p>
            <h:outputFormat value="You have not selected the valid code: '{0}' is not recognized.">
                <f:param value="#{param['code']}"/>
            </h:outputFormat>
        </p>
    </c:otherwise>
</c:choose>